package it.polimi.meteocal.web.beans;


import java.util.List;

import it.polimi.meteocal.ejb.eventmanagement.EventDTO;
import it.polimi.meteocal.ejb.eventmanagement.EventMgr;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;


@ManagedBean(name="eventBean")
@RequestScoped
public class EventBean {

	@EJB
	private EventMgr eventMgr;

	private EventDTO event;
	
	private List<?> result;
	
	public EventBean() {
		event = new EventDTO();
	}
	
	public EventDTO getEvent() {
		return event;
	}

	public void setEvent(EventDTO event) {
		this.event = event;
	}

	public EventMgr getEventMgr() {
		return eventMgr;
	}

	public void setEventMgr(EventMgr eventMgr) {
		this.eventMgr = eventMgr;
	}

	public List<?> getResult() {
		return result;
	}

	public void setResult(List<?> result) {
		this.result = result;
	}

	public String createEvent() {
		eventMgr.save(event);
		return "invite?faces-redirect=true";
	}
	
	public String findMyEvents(){
		result = eventMgr.findMyEvents();
		return "notification?faces-redirect=true";
	}
	 
	public String deleteEvent(int eventid){
		eventMgr.delete(eventid);
		return "personal?faces-redirect=true";
	}
}
